﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CCWin;
using CRegex;
namespace weiqijiance.工位配置
{
    public partial class LIsetting : CCSkinMain
    {
        public LIsetting()
        {
            InitializeComponent();
        }

        private void LIsetting_Load(object sender, EventArgs e)
        {

            iniclass objini = new iniclass();
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\安综检仪表配置.ini";
            string path1 = string.Format(@"{0}", path);
            objini.Ini(path1);
            tex_dgck.Text = objini.ReadValue("灯光", "灯光仪串口设置").Trim();
            com_type.Text = objini.ReadValue("灯光", "灯光仪型号").Trim();
     
            check_zkw.Checked = (objini.ReadValue("灯光", "仪器左靠位").Trim() == "1") ? true : false;
            check_ygpybpj.Checked = (objini.ReadValue("灯光", "安检远光偏移不评价").Trim() == "1") ? true : false;
            check_jgpybpj.Checked = (objini.ReadValue("灯光", "安检近光偏移不评价").Trim() == "1") ? true : false;
            check_needpy.Checked = (objini.ReadValue("灯光", "平台需要显示偏移").Trim() == "1") ? true : false;
            check_ld.Checked = (objini.ReadValue("灯光", "只检两灯").Trim() == "1") ? true : false;
            check_pyxz.Checked = (objini.ReadValue("灯光", "综检偏移限值采用安检标准").Trim() == "1") ? true : false;
            check_jcxjs.Checked = (objini.ReadValue("灯光", "检测线结束设备").Trim() == "1") ? true : false;
            tex_sjck.Text = objini.ReadValue("声级", "声级计串口设置").Trim();
            tex_xssj.Text = objini.ReadValue("灯光", "信息显示时间").Trim();
            check_hwsx.Checked = (objini.ReadValue("灯光", "灯光后红外是否失效").Trim() == "1") ? true : false;
            che_ddzj.Checked = objini.ReadValue("灯光", "只检单独综检").Trim().Contains("是") ? true : false;
            check_ssxt.Checked = objini.ReadValue("灯光", "采用双摄像头").Trim() == "1" ? true : false;

            tex_ksys.Text = objini.ReadValue("灯光", "开始延时").Trim();
            tex_jsys.Text = objini.ReadValue("灯光", "结束延时").Trim();

            cb_sfdwjc.Checked = objini.ReadValue("灯光", "定位控制").Trim().Contains("是") ? true : false;
            tb_dwtime.Text = objini.ReadValue("灯光", "定位时间").Trim();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            CRegex.C_Regex.checkcom(tex_dgck.Text,true);

            iniclass objini = new iniclass();
            string path = "";
            path = System.Windows.Forms.Application.StartupPath + path + "\\安综检仪表配置.ini";
            string path1 = string.Format(@"{0}", path);
            objini.Ini(path1);
            objini.Writue("灯光", "灯光仪串口设置", tex_dgck.Text);
            objini.Writue("灯光", "仪器左靠位", check_zkw.Checked ? "1" : "0");
            objini.Writue("灯光", "安检远光偏移不评价", check_ygpybpj.Checked ? "1" : "0");
            objini.Writue("灯光", "安检近光偏移不评价", check_jgpybpj.Checked ? "1" : "0");
            objini.Writue("灯光", "平台需要显示偏移", check_needpy.Checked ? "1" : "0");
            objini.Writue("灯光", "只检两灯", check_ld.Checked ? "1" : "0");
            objini.Writue("灯光", "综检偏移限值采用安检标准", check_pyxz.Checked ? "1" : "0");
            objini.Writue("灯光", "检测线结束设备", check_jcxjs.Checked ? "1" : "0");
            objini.Writue("声级", "声级计串口设置", tex_sjck.Text);
            objini.Writue("灯光", "信息显示时间", tex_xssj.Text);
            objini.Writue("灯光", "灯光仪型号", com_type.Text);
            objini.Writue("灯光", "灯光后红外是否失效", check_hwsx.Checked ? "1" : "0");

            objini.Writue("灯光", "只检单独综检", che_ddzj.Checked ? "是" : "否");
            objini.Writue("灯光", "采用双摄像头", check_ssxt.Checked ? "1" : "0");

            objini.Writue("灯光", "开始延时", tex_ksys.Text);
            objini.Writue("灯光", "结束延时", tex_jsys.Text);

            objini.Writue("灯光", "定位控制", cb_sfdwjc.Checked ? "是" : "否");
            objini.Writue("灯光", "定位时间", tb_dwtime.Text);
            MessageBox.Show("完成");
            基类窗体.UploadAndDownload fupload = new 基类窗体.UploadAndDownload();
            objini.Ini(System.Windows.Forms.Application.StartupPath + "\\系统信息.ini");
            string sjcxname = objini.ReadValue("系统信息", "检测线名称");
            string sgongweiname = objini.ReadValue("系统信息", "检测工位名称");
            fupload.upload(sjcxname, sgongweiname, "安综检仪表配置.ini");
        }

        private void LIsetting_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F8)
            {
                label6.Visible = true;
                label7.Visible = true;
                tex_ksys.Visible = true;
                tex_jsys.Visible = true;
            }
        }

        private void com_type_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}
